home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / brklyprl.lha / Emulator / top_level.h < prev   
Encoding:
C/C++ Source or Header  |  1989-04-14  |  2.5 KB  |  116 lines

  1.  
  2. /* Copyright (C) 1988, 1989 Herve' Touati, Aquarius Project, UC Berkeley */
  3.  
  4. /* Copyright Herve' Touati, Aquarius Project, UC Berkeley */
  5.  
  6. extern void top_level();
  7. extern void init_commands();
  8. extern int window_size;
  9.  
  10. typedef void (*PFI)(int);
  11.  
  12. struct Command {
  13.   char* name;
  14.   int ID;
  15.   PFI exec;
  16.   int arg_type;
  17. };
  18.  
  19. extern Command commands[];
  20.  
  21. enum {
  22. #define NAMES
  23. #define use(String,ID,Function,ARGTYPE)\
  24.   ID,
  25. #include "commands.h"
  26. #undef use
  27. #undef NAMES
  28. LAST_COMMAND
  29. };
  30.  
  31. #define NAMES
  32. #define use(String,ID,Function,ARGTYPE)\
  33. extern void Function(int);
  34. #include "commands.h"
  35. #undef use
  36. #undef NAMES
  37.  
  38. extern void service_interrupt();
  39. extern void service_illegal_instruction();
  40. extern void service_bus_error();
  41. extern void service_segmentation_fault();
  42. extern void service_error(char*);
  43. extern void top_level_error(char* s =0);
  44. extern void top_level_failure();
  45. extern void top_level_success();
  46. extern void top_level_normal_termination();
  47.  
  48. extern int BREADTH_LIMIT;
  49. extern int DEPTH_LIMIT;
  50.  
  51. typedef struct {
  52. #ifdef WITH_GC
  53.   int new_space_underflow;
  54. #endif
  55.   int end;
  56.   int last_low;
  57.   int maximum;
  58.   int total;
  59.   void clear() {
  60.     end = last_low = maximum = total = 0;
  61. #ifdef WITH_GC
  62.     new_space_underflow = 0;
  63. #endif
  64.   }
  65.   void enter(Cell* Low, Cell* High) {
  66. #ifdef WITH_GC
  67.     Cell low = ((Low >= HMIN) ? (Low - HMIN) + (H2 - H0) : (Low - H0));
  68.     Cell high = (High - HMIN) + (H2 - H0);
  69.     if (Low < HMIN && end == 0) new_space_underflow++;
  70. #else
  71.     Cell low = Low - H0;
  72.     Cell high = High - H0;
  73. #endif
  74.     total += high - last_low;
  75.     last_low = low;
  76.     maximum = (maximum > high) ? maximum : high;
  77.   }
  78. #ifdef WITH_GC
  79.   void gc_enter(Cell* H_before, Cell* H2_before) {
  80.     Cell before = (H_before - HMIN) + (H2_before - H0);
  81.     Cell after = (H2 - H0);
  82.     total += before - last_low;
  83.     last_low = after;
  84.     maximum = (maximum > before) ? maximum : before;
  85.   }
  86. #endif
  87.   void print() {
  88.     printf("Total Cells Allocated: %d\n", total);
  89.     printf("Maximum Number of Cells in Use: %d\n", maximum);
  90. #ifdef WITH_GC 
  91.     printf("New Space Underflows: %d\n", new_space_underflow);
  92. #endif
  93.   }
  94. } HeapData;
  95.  
  96. extern HeapData heap_usage;
  97. extern int trace_heap_flag;
  98.  
  99. struct StackData {
  100.   Cell* max_e;
  101.   Cell* min_b;
  102.   inline void enter(Cell* e, Cell* b) {
  103.     max_e = (max_e > e) ? max_e : e;
  104.     min_b = (min_b < b) ? min_b : b;
  105.   }
  106.   void clear() {
  107.     max_e = E0;
  108.     min_b = B0;
  109.   }
  110.   void print() {
  111.     printf("Max Number of Words in Env Stack: %d\n", max_e - E0);
  112.     printf("Max Number of Words in CP Stack: %d\n", B0 - min_b);
  113.   }
  114. };
  115.  
  116.